#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
int pid1,pid2;
int EndFlag=0;
int pf1=0;
int pf2=0;
void IntDelete()
{
	kill(pid1,16);
	kill(pid2,17);

}
void Int1()
{
	printf("child process 1 is killed !by parent\n");
	exit(0);
}
void Int2()
{
	printf("child process 2 is killed !by parent\n");
	exit(0);
}
int main()
{
	int exitpid;
	if(pid1=fork())
	{
	      if(pid2=fork())
	      {
		signal(SIGINT,IntDelete);
		waitpid(-1,&exitpid,0);
		waitpid(-1,&exitpid,0);
		printf("parent process is killed\n");
		exit(0);
	       }
	       else
	       {
		 signal(SIGQUIT, SIG_IGN);  //signal(SIGQUIT,SIG_IGN)忽略中断信号
		 signal(17,Int2);
		 pause();
	        }
	}
	else
	{
		signal(SIGQUIT, SIG_IGN);   //signal(SIGQUIT,SIG_IGN)忽略中断信号
		signal(16,Int1);
		pause();
	}
}
